package org.point.controller;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletResponse;

import org.point.common.controller.BaseController;
import org.point.common.util.DoPage;
import org.point.domain.UserLogin;
import org.point.domain.UserSign;
import org.point.service.ProductTypeService;
import org.point.service.UserSignService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.alibaba.fastjson.JSONObject;

/**
 * 
 * @ClassName: ProductController  
 * @Description: TODO(这里用一句话描述这个类的作用)  
 * @author Kenny_Z' szqiuk@gmail.com
 * @date 2016年10月23日 下午9:18:34  
 *
 */
@Controller
@RequestMapping("/UserSign/")
public class UserSignController extends BaseController {
	
	@Autowired
	private UserSignService service;
	
	@RequestMapping(value="UserSignList.do", method = RequestMethod.POST, produces = "text/plain;charset=UTF-8")
	public void UserSignList(@RequestParam(value = "memberId") String memberId, @RequestParam(value = "currentPage") Integer currentPage, HttpServletResponse response){
		DoPage<UserSign> page = new DoPage<UserSign>();
		Map<String, Object> map = new HashMap<String, Object>();
		JSONObject jsonObj = new JSONObject();
		try {
			if(memberId.trim().length() > 0 && memberId != null){
				map.put("memberId", memberId);
				if(currentPage != null){
					map.put("firstRecord", page.getFirstRecord());
					map.put("pageSize", page.getPageSize());
					page.setCurrentPage(10);
					page.setMap(map);
					// 查询商品分类数据分页返回数据
					DoPage<UserSign> resultPage = service.searchCRForPage(page);
					// 商品数据分页返回成功及返回状态
					jsonObj.put("page", resultPage);
					jsonObj.put("resultMsg", 1);
				} else {
					jsonObj.put("resultMsg", -2);
				}
			} else {
				// 参数传递错误，会员单位ID为空！
				jsonObj.put("resultMsg", -1);
			}
		} catch (Exception e) {
			// 网络错误，请联系管理员！
			jsonObj.put("resultMsg", 0);
			throw new RuntimeException("商品查询出错!", e);
		} finally {
			try {
				feedback(response, jsonObj.toString());
			} catch (IOException e) {
				throw new RuntimeException("网络错误，请联系管理员！", e);
			}
		}
	}
}
